<template>
	<view>
		<uni-calendar 
		    :date="startTime"
			:insert="true"
			:start-date="startTime"
			:end-date="endTime"
			:selected="prices"
			 />
	</view>
</template>

<script>
	import {priceCalendar} from '@/api/home-api.js'
	const moment = require('@/utils/moment.js');
	export default {
		data() {
			return {
				planId : '',
				prices: []
			}
		},
		onLoad(op) {
           this.planId = op.planId;
		   this.getPriceCalendar();
		},
		computed: {
			businessNo() {
				return this.$store.state.order.businessNo;
			}, 
		   startTime() {
			   return this.$store.state.order.startTime;
		   },
		   endTime() {
			   return this.$store.state.order.endTime;
		   },
		   startTimeDate() {
			   return moment(this.startTime, "YYYY-MM-DD");
		   }
		},
		methods: {
             getPriceCalendar() {
				 uni.showLoading({
				 	title: '价格查询中...'
				 })
				 priceCalendar({
					 tenantId : this.$store.state.user.tenantId,
					 planId : this.planId,
					 startTime : this.startTime,
					 endTime : this.endTime,
					 bizType : this.businessNo
				 }).then(res=> {
					 uni.hideLoading();
					 this.prices = res.data;
					 for (let price of this.prices) {
					 	price.date = price.time;
						price.info = '¥'+ price.price;
					 }
				 })
			 }
		}
	}
</script>

<style lang="scss" scoped>
	
</style>
